/**
 * @example SDLvncviewer.c
 */

#include <SDL.h>
#include <signal.h>
#include "rfb/rfbclient.h"
#include "SDL_rotozoom.h"
#include "SDL_Tools.h"

SDL_Surface* mainSurface;
SDL_Surface* rfbClientSurface;

static rfbBool resize(rfbClient* client) {
	int width = client->width;
	int height = client->height;
	int depth = client->format.bitsPerPixel;



	client->updateRect.x = client->updateRect.y = 0;
	client->updateRect.w = width;
	client->updateRect.h = height;

	Uint32 rmask, gmask, bmask, amask;
	    /* SDL interprets each pixel as a 32-bit number, so our masks must depend
	       on the endianness (byte order) of the machine */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
	rmask = 0xff000000;
	gmask = 0x00ff0000;
	bmask = 0x0000ff00;
	amask = 0x000000ff;
#else
	rmask = 0x000000ff;
	gmask = 0x0000ff00;
	bmask = 0x00ff0000;
	amask = 0xff000000;
#endif

	rfbClientSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, depth,
	                                   rmask, gmask, bmask, amask);

	rfbClientSetClientData(client, SDL_Init, rfbClientSurface);
	client->width = rfbClientSurface->pitch / (depth / 8);

	client->frameBuffer = sdl->pixels;

	client->format.bitsPerPixel = depth;
	client->format.redShift = rfbClientSurface->format->Rshift;
	client->format.greenShift = rfbClientSurface->format->Gshift;
	client->format.blueShift = rfbClientSurface->format->Bshift;
	client->format.redMax = rfbClientSurface->format->Rmask >> client->format.redShift;
	client->format.greenMax = rfbClientSurface->format->Gmask
			>> client->format.greenShift;
	client->format.blueMax = rfbClientSurface->format->Bmask >> client->format.blueShift;

	SetFormatAndEncodings(client);

	return TRUE;
}

int main(int argc, char** argv) {

	SDL_Init(SDL_INIT_VIDEO );

	//int width = 1920;
	//int height = 1080;
	int width = 960;
	int height = 540;

	SDL_Log("width : %d _ height : %d ",width,height);

	mainSurface = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_FULLSCREEN);

	return 0;
}

